import request from '@/utils/request'
import { isNotEmpty } from '@/utils'
import { getItem } from '@/utils/auth'

export function fetchList(data) {
  return request({
    url: '/cloud-system/getErrorLogList',
    method: 'post',
    data
  })
}

export function getSiteList(parameter, result) {
  const data = JSON.parse(getItem('baseParam'))
  // data.orderArray = 'orderSeq=1'
  if (isNotEmpty(parameter)) {
    data.parameterArray += (',' + parameter)
  }
  if (isNotEmpty(result)) {
    data.resultArray += (',' + result)
  }
  return request({
    url: '/cloud-system/getSiteList',
    method: 'post',
    data
  })
}
export function getOrganizationList(parameter, result) {
  const data = JSON.parse(getItem('baseParam'))
  // data.orderArray = 'orderSeq=1'
  if (isNotEmpty(parameter)) {
    data.parameterArray += (',' + parameter)
  }
  if (isNotEmpty(result)) {
    data.resultArray += (',' + result)
  }
  return request({
    url: '/cloud-system/getOrganizationList',
    method: 'post',
    data
  })
}

export function getCategoryList(parameter, result) {
  const data = JSON.parse(getItem('baseParam'))
  // data.orderArray = 'orderSeq=1'
  if (isNotEmpty(parameter)) {
    data.parameterArray += (',' + parameter)
  }
  if (isNotEmpty(result)) {
    data.resultArray += (',' + result)
  }
  return request({
    url: '/cloud-system/getCategoryList',
    method: 'post',
    data
  })
}
export function getUserList(parameter, result) {
  const data = JSON.parse(getItem('baseParam'))
  // data.orderArray = 'orderSeq=1'
  if (isNotEmpty(parameter)) {
    data.parameterArray += (',' + parameter)
  }
  if (isNotEmpty(result)) {
    data.resultArray += (',' + result)
  }
  return request({
    url: '/cloud-system/getUserList',
    method: 'post',
    data
  })
}
